﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

public partial class UserControl_Videos : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            StringBuilder sb = new StringBuilder();
            using (Up1VNDataContext dc = new Up1VNDataContext())
            {
                var videos = (from v in dc.SupportLinks where v.SupportLink_Type == 2 orderby v.SupportLink_Id descending select v).Take(5).ToList();
                if (videos.Count > 0)
                {
                    foreach (var item in videos)
                    {
                        sb.Append("<li><a href='" + ResolveUrl("~/Webdirectory/Videos/" + item.SupportLink_Link) + "'>" + item.SupportLink_Name + "</a></li>");
                    }
                }
                else
                {
                    DataSet ds = new DataSet();
                    ds.ReadXml(Server.MapPath("~/App_Data/VideoClips.xml"));
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        sb.Append("<li><a href='" + dr["linkyt"] + "'>" + dr["title"] + "</a></li>");
                    }
                }
            }
            ltrVideoClip.Text = sb.ToString();
        }
        catch(Exception ex)
        { 
            
        }
    }
}